﻿using System.Collections.Generic;

namespace EternitySolver.Core.Solvers.FixedPath
{
    public class ReverseSpiralSolver : FixedPathSolver
    {
        public override LinkedList<int> GetPath(Board board)
        {
            var spiral = new SpiralSolver();
            var path = spiral.GetPath(board);
            var reversed = new LinkedList<int>();
            var pathnode = path.Last;
            var node = reversed.AddFirst(pathnode.Value);
            do
            {
                pathnode = pathnode.Previous;
                node = reversed.AddAfter(node, pathnode.Value);

            } while (reversed.Count < path.Count);
            return reversed;
        }
        public override string ToString()
        {
            return "Reverse Sprial Solver";
        }
    }
}